package com.aaa.controller;

import com.aaa.entity.Texture;
import com.aaa.service.impl.TextureServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("texture")
@RestController
public class TextureController {
    @Resource
    TextureServiceImpl textureService;

    @RequestMapping("find")
    public List<Texture> find(){
        return textureService.find();
    }

    @RequestMapping("add")
    @ResponseBody
    public int add(Texture texture){
        return textureService.add(texture);
    }
    @RequestMapping("update")
    @ResponseBody
    public int update(Texture texture){
        return textureService.update(texture);
    }
    @RequestMapping("delete")
    @ResponseBody
    public int find(Integer id){
        return textureService.delete(id);
    }


    @ResponseBody
    @RequestMapping("findpage")
    public Map<String, Object> userList(Integer pageSize, Integer pageNum) {
        Map<String, Object> map = new HashMap<>();
        List<Texture> userList = textureService.findpage(pageSize, pageNum * pageSize);
        Integer TotalNum = textureService.findcount();

        map.put("userList", userList);
        map.put("TotalNum", TotalNum);
        return map;
    }


}
